//
//  YYMainVC.swift
//  SinaWeibo
//
//  Created by 王朝阳 on 2017/5/11.
//  Copyright © 2017年 王朝阳. All rights reserved.
//

import UIKit

class YYMainVC: UITabBarController {

    override func viewDidLoad() {
        super.viewDidLoad()
        
        addChildViewControllers(YYHomeVC(), title: "首页", imageName: "tabbar_home")
        addChildViewControllers(YYMessageVC(), title: "消息", imageName: "tabbar_message_center")
        addChildViewControllers(YYDiscoverVC(), title: "发现", imageName: "tabbar_discover")
        addChildViewControllers(YYMineVC(), title: "我", imageName: "tabbar_profile")
        
    }
    
//MARK: - 创建子控制器
    private func addChildViewControllers(_ vc: UIViewController, title: String, imageName: String) {

        vc.title = title
        //设置选中后的文字
        vc.tabBarItem.setTitleTextAttributes([NSForegroundColorAttributeName: UIColor.orange], for: .selected)
        vc.tabBarItem.image = UIImage(named: imageName)
        vc.tabBarItem.selectedImage = UIImage(named:"\(imageName)_selected")?.withRenderingMode(UIImageRenderingMode.alwaysOriginal)
        let nav = UINavigationController(rootViewController: vc)
        addChildViewController(nav)
    }

}
